package com.himore.api.web.controller.modules;

import java.util.List;

import com.himore.api.web.model.TTaskCompleteInfo;
import com.himore.api.web.service.ITTaskCompleteInfoService;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.himore.api.common.annotation.Log;
import com.himore.api.common.core.controller.BaseController;
import com.himore.api.common.core.domain.AjaxResult;
import com.himore.api.common.enums.BusinessType;

import com.himore.api.common.utils.poi.ExcelUtil;
import com.himore.api.common.core.page.TableDataInfo;

/**
 * 任务信息Controller
 * 
 * @author ruoyi
 * @date 2021-01-21
 */
@Api(tags = "已完成信息管理")
@RestController
@RequestMapping("/system/completeInfo")
public class TTaskCompleteInfoController extends BaseController
{
    @Autowired
    private ITTaskCompleteInfoService tTaskCompleteInfoService;

    /**
     * 查询任务信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TTaskCompleteInfo tTaskCompleteInfo)
    {
        startPage();
        List<TTaskCompleteInfo> list = tTaskCompleteInfoService.selectTTaskCompleteInfoList(tTaskCompleteInfo);
        return getDataTable(list);
    }

    /**
     * 导出任务信息列表
     */
    @Log(title = "任务信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TTaskCompleteInfo tTaskCompleteInfo)
    {
        List<TTaskCompleteInfo> list = tTaskCompleteInfoService.selectTTaskCompleteInfoList(tTaskCompleteInfo);
        ExcelUtil<TTaskCompleteInfo> util = new ExcelUtil<TTaskCompleteInfo>(TTaskCompleteInfo.class);
        return util.exportExcel(list, "info");
    }

    /**
     * 获取任务信息详细信息
     */
    @GetMapping(value = "/{infoId}")
    public AjaxResult getInfo(@PathVariable("infoId") Long infoId)
    {
        return AjaxResult.success(tTaskCompleteInfoService.selectTTaskCompleteInfoById(infoId));
    }

    /**
     * 新增任务信息
     */
    @Log(title = "任务信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTaskCompleteInfo tTaskCompleteInfo)
    {
        return toAjax(tTaskCompleteInfoService.insertTTaskCompleteInfo(tTaskCompleteInfo));
    }

    /**
     * 修改任务信息
     */
    @Log(title = "任务信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTaskCompleteInfo tTaskCompleteInfo)
    {
        return toAjax(tTaskCompleteInfoService.updateTTaskCompleteInfo(tTaskCompleteInfo));
    }

    /**
     * 删除任务信息
     */
    @Log(title = "任务信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{infoIds}")
    public AjaxResult remove(@PathVariable Long[] infoIds)
    {
        return toAjax(tTaskCompleteInfoService.deleteTTaskCompleteInfoByIds(infoIds));
    }
}
